#include "ModuleData.h"

#include <iostream>
#include "ChannelData.h"


ModuleData::ModuleData(string name)
{
	mName = name;
}

ModuleData::~ModuleData()
{

}

void ModuleData::addProcess(Process* process)
{
	mProcessList.push_front(process);
}

void ModuleData::addChannelData(ChannelData* channelData)
{
	mChannelDataList.push_front(channelData);
}
	
void ModuleData::addModuleData(ModuleData* moduleData)
{
	mModuleDataList.push_front(moduleData);
}

list<ModuleData*>* ModuleData::getModuleDataList()
{
	return &mModuleDataList;
}

list<ChannelData*>* ModuleData::getChannelDataList()
{
	return &mChannelDataList;
}

list<Process*>* ModuleData::getProcessList()
{
	return &mProcessList;
}

string ModuleData::getName()
{
	return mName;
}

void ModuleData::debug(int level)
{
	cout.write(" ", level);
	cout << mName << endl;
	for (list<ChannelData*>::iterator i = mChannelDataList.begin(); i != mChannelDataList.end(); i++)
	{
		cout.write(" ", level+1);
		cout << (*i)->getSourceName() << ":" << (*i)->getSourceType() << " -> " << (*i)->getTargetName() << ":" << (*i)->getTargetType() << endl;
	}

	for (list<Process*>::iterator j = mProcessList.begin(); j != mProcessList.end(); j++)
	{
		cout.write(" ", level+1);
		cout << (*j)->getName() << ":" << (*j)->getType() << endl;
	}

	for (list<ModuleData*>::iterator k = mModuleDataList.begin(); k != mModuleDataList.end(); k++)
	{
		(*k)->debug(level+1);
	}
}

void ModuleData::addPortData(PortData* portData)
{
	mPortDataList.push_back(portData);
}

list<PortData*>* ModuleData::getPortDataList()
{
	return &mPortDataList;
}